<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Tools {
	
	var $CI;
    
	function Tools(){				
		$this->CI = &get_instance();
		$this->CI->load->database();
	}
        
        function getBab($id){
		
		if($id==0){
			return "-";	
		}
		$this->CI->db->where('id',$id);
		$data = $this->CI->db->get('project_bab')->row();
	    
		return $data->bab;
        }
        
        function getPekerjaan($kode){
		
		if($kode==0){
			return "-";	
		}
		$this->CI->db->where('kode',$kode);
		$data = $this->CI->db->get('project_pekerjaan')->row();
	    
		return $data->kode." - ".$data->uraian;
        }
        
        function getChildBab($id){
		
		if($id==0){
			return "-";	
		}
		$this->CI->db->where('parent',$id);
		$data = $this->CI->db->get('project_bab');
		if($data->num_rows()>0){
			return $data->result_array();	
		}else{
			return null;
		}
        }
	
        function getBoq($id){
		$this->CI->db->where('id_bab',$id);
		$data = $this->CI->db->get('project_boq');
		return $data->result_array();	
        }
	
        function getRencanaBoq($pay_item){
		$this->CI->db->where('pay_item',$pay_item);
		$data = $this->CI->db->get('project_boq');
		return $data->row();	
        }
        
        function getStation($id){
		
		if($id==0){
			return "-";	
		}
		$this->CI->db->where('id',$id);
		$data = $this->CI->db->get('project_station')->row();
	    
		return $data->kodepier." [ ".$data->sisi." ] ".$data->type;
        }
}

?>